package socketmvc.core.util;

import java.util.function.Supplier;

/**
 * Created by Administrator on 2018/1/15.
 *
 */
public class StringUtils {
    public static boolean isNotEmpty(String s){
        return s!=null&&!"".equals(s);
    }
    public static boolean isEmpty(String s){
        return s==null||"".equals(s);
    }


    public static ToStringLazy toStringLazy(Supplier<?> supplier) {
        return new ToStringLazy(supplier);
    }


    public static class ToStringLazy {
        private final Supplier<?> stringSupplier;
        public ToStringLazy(final Supplier<?> supplier) {
            this.stringSupplier = supplier;
        }
        @Override
        public String toString() {
            return String.valueOf(stringSupplier.get());
        }
    }
}
